The code below is my first attempt at using an NC
touch probe to find the center of a circle and move to
it. Does this look like a viable approach?
Should the touch probe be connected to an opto input?
#include "KMotionDef.h"
#include "PC-DSP.h"
double maxX= 2000*14/16*5*2; //
2000*14/16*5*inchesRadius
double maxY= 2000*14/18*5*2; //
2000*14/18*5*inchesRadius
double Xspeed=1143; //
IPS=rot/step*in/rot*rot/rot*step/second =
.1/(1/2000*14/16*.2)
double Yspeed=1286; //.1/(1/2000*14/18*.2)
// int GetDROs(double *DROx, double *DROy, double
*DROz, double *DROa, double *DROb, double *DROc);
int probeBit=;
double x[3];
double y[3];
double XX;
double YY;
#define X 0
#define Y 1
#define Z 2
main()
{
printf("Starting centerfind X\n");
x[0] = ch0->Dest;
y[0] = ch1->Dest;
Jog(X, Xspeed);
while(ReadBit(probeBit) && ch0->Dest
< x[0] + maxX)
Jog(X, 0);
while(!CheckDone(X))
x[1] = ch0->Dest;
Jog(X, -Xspeed);
while(ReadBit(probeBit) && ch0->Dest
> x[0] - maxX)
Jog(X, 0);
while(!CheckDone(X))
x[2] = ch0->Dest;
Move(X, (x[1]-x[2])/2);
while(ReadBit(probeBit) && !CheckDone(X))
printf("Starting centerfind Y\n");
y[0] = ch1->Dest;
Jog(Y, Yspeed);
while(ReadBit(probeBit) && ch1->Dest
< y[0] + maxY)
Jog(Y, 0);
while(!CheckDone(Y))
Y[1] = ch1->Dest;
Jog(Y, -Yspeed);
while(ReadBit(probeBit) && ch1->Dest
> y[0] - maxY)
Jog(Y, 0);
while(!CheckDone(Y))
y[2] = ch1->Dest;
Move(Y, (y[1]-y[2])/2);
while(ReadBit(probeBit) && !CheckDone(y))
printf("Finished centerfind \n");
}